package com.hy.admin.service.impl;

import com.hy.admin.dao.*;
import com.hy.admin.entity.MemberEntity;
import com.hy.admin.entity.MemberIncomeEntity;
import com.hy.admin.entity.YangCardEntity;
import com.hy.admin.helper.response.PersonalResponse;
import com.hy.admin.service.PersonalService;
import com.hy.admin.service.YangCardService;
import com.hy.core.response.ServicesResult;
import org.apache.commons.httpclient.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by yangqq on 18/4/4.
 */
@Service
public class YangCardServiceImpl implements YangCardService {
    @Autowired
    private YangCardDao yangCardDao;

    @Override
    public ServicesResult<List<YangCardEntity>> list(){
        ServicesResult<List<YangCardEntity>> servicesResult = new ServicesResult<>();
        //查询所有氧卡
        List<YangCardEntity> yangCardList = yangCardDao.selectAll();
        servicesResult.setResult(yangCardList);
        return servicesResult;
    }

    @Override
    public ServicesResult<YangCardEntity> detail(Long id){
        ServicesResult<YangCardEntity> servicesResult = new ServicesResult<>();
        //校验请求参数
        if (id == null || id < 0){
            servicesResult.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
            servicesResult.setStatusMsg("请求报文有误");
            return servicesResult;
        }
        //查询氧卡
        YangCardEntity yangCardEntity = yangCardDao.selectByPrimaryKey(id);
        servicesResult.setResult(yangCardEntity);
        return servicesResult;
    }

}
